<?php
# ADMIN.PHP
# Display pages and modules
# Run as frame in index.php

session_start();
ob_start();

define('INDEX',true);

// Include required files
require("_config/config.php"); // Config file
require("_config/db_connection.php"); // DB Connection
require("common/functions_mysql.php"); // MySQL class
require("common/functions_common.php"); // Common functions
require("common/functions_template.php"); // Templates functions
require("common/functions_jcas.php"); // jCAS's function
require("common/init.php"); // Initial file
require("common/lang_".$cfg['admin_language'].".php"); // Language file
require("core/class_jcas.php"); // Core jcas
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php echo $cfg['admin_header']?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $cfg['default_charset']; ?>">
<link href="css/style.css" rel="stylesheet" type="text/css">
<link href="js/datepicker/datePicker.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script src="js/functions.js" language="JavaScript" type="text/javascript"></script>
<script src="js/datepicker/date.js" language="JavaScript" type="text/javascript"></script>
<script src="js/datepicker/jquery.datePicker.js" language="JavaScript" type="text/javascript"></script>
<!--<script src="js/mm_menu.js" language="JavaScript" type="text/javascript"></script>-->
<!-- start text editor scripts -->
<script type="text/javascript" src="js/tiny_mce/plugins/tinybrowser/tb_tinymce.js.php"></script>
<script type="text/javascript" src="js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
	mode : "textareas",
	theme : "advanced",
	elements : "abshosturls",
	relative_urls : false,
	remove_script_host : false,
	file_browser_callback : "tinyBrowser",
	theme_advanced_buttons1 : "fontselect,fontsizeselect,bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,undo,redo,link,unlink,code",
	theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,outdent,indent,blockquote,|,image,media,|,forecolor,backcolor,tablecontrols",
    	theme_advanced_buttons3 : "",
    	theme_advanced_toolbar_location : "top",
    	theme_advanced_toolbar_align : "left",
    	theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
    	plugins : 'safari,inlinepopups,media,table,advlink,advimage,paste',
	editor_selector : "editor"
});
</script>
<!-- end text editor scripts -->


</head>
<body>
<table width="99%"  border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
	<div id="top_banner">
	 <table width="100%"  border="0" cellpadding="0" cellspacing="0" align="center">
      <tr>
        <td colspan="10" align="center" valign="top"  class="topheadtd">
		    <table width="100%"  border="0" cellspacing="0" cellpadding="1">
            <tr>
              <td align="left" width="50%">
			  <font class="module_header"><?php echo $cfg['admin_header'];?></font>
                <input name="button" type="button" class="button_small" onClick="window.location.reload();" value="Refresh"></td>
              <td align="right" height="50%"><font color="white"><?php printf($lang["logged_in_as"],@$admin_session["admin_user"]);?></font> <input type="button" class="button btn_logout" value="<?php echo $lang['btn_logout']?>" onClick="ask('login.php?act=logout','<?php echo $lang['js_confirm_logout']?>');"></td>
            </tr>
            <tr>
              <td align="left"><font class="module_title"><?php echo main_show_page_title()?></font></td>
              <td align="right" height="50%">&nbsp;</td>
            </tr>
          </table>
		  
		  </td>
      </tr>
    </table>
	</div>
	 <div id="sub_nav">
     <table width="100%" border="0" cellspacing="0" cellpadding="0">
     <tr>
	 <td bgcolor="#EEEEEE" class="datatd"><?php echo main_show_flags() ?></td>
     <td bgcolor="#EEEEEE" class="datatd"><?php echo main_show_jcas_modules() ?></td>
     </tr>
     </table>
	 </div>

<?php
// Check if admin is allowed to access this modules
if($_GET['mdl'] != 'jcas_home') 
{
	if(!main_check_privilege("view"))
	{
		die(message($lang['not_allowed_to_access'],"error"));
		exit;
	}
}

// Module folder
$mdl_folder = main_get_module_folder($_GET["mdl"]);

// Building page
if(is_file($mdl_folder.$_GET["mdl"].'.php'))
{
	require($mdl_folder.$_GET["mdl"].'.php');
}
else echo message(sprintf($lang["unknown_module"],$_GET["mdl"]),'error');

// Switch page
main_switch_page();
?> 
<br>
	
	<?php if(@$admin_session["id"]) { ?>
		<div id="admin_info">
		<table width="100%"  border="0" cellpadding="0" cellspacing="0">
		<tr>
		<td width="90%" class="bottomtd">
				<?php printf($lang['ip_and_time'],$_SERVER['REMOTE_ADDR'],show_date("H:i:s d/m/Y",$time),$cfg['default_timezone'])?>			 
		</td>
		<td width="10%" align="right" class="bottomtd">
			<img src="images/top.gif" width="21" height="19" border="0" style="cursor:hand " onClick="window.location='#top'">
		</td>
		</tr>
		</table>
		</div>
	<?php } ?>
	
	<!-- start footer -->
	<!-- end footer -->
</td>
</tr>
</table>
<!-- Alert using javascript -->
<script language="javascript">
$('input[name=name]').blur(function(){
	var str=$(this).val();
	if(str!=''){
			$.post('do_convert_alias.php',{name:str} ,function(resp){
				$('input[name=alias]').val(resp);			  
			});	
	}
});
var message;
if(message) alert(message);
</script>
</body>
</html>
<?php
$DB->close();
require("common/debug.inc.php");
ob_end_flush();
?>
